<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //数组排序
        //1.翻转数组
        var arr = ['pink', 'red', 'blue'];
        arr.reverse();  //数组翻转
        console.log(arr);

        //数组冒泡
        var arr1 = [13, 4, 72, 1];
        arr1.sort();   //冒险排序 ，双位数组排序有问题
        arr1.sort(function (a, b) {
            return a - b;    //a-b按照升序排序，b-a是降序排序
        })
        console.log(arr1);

        //解决双位数的排序问题
        // arr1.sort(function (a, b) {
        //     return a - b;
        // })

    </script>
</head>

<body>

</body>

</html>